package com.springboot3.test.springboot3testdemo4.demos.web.config;

import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import java.io.InputStream;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/8/23-13:39
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Configuration
public class JsonSchemaConfiguration {
  private static final String SCHEMA_VALIDATION_FILE = "validation.json";

  @Bean
  public JsonSchema jsonSchema() {
    final InputStream inputStream =
        Thread.currentThread().getContextClassLoader().getResourceAsStream(SCHEMA_VALIDATION_FILE);
    return JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7).getSchema(inputStream);
  }
}
